package cn.leestudio.leelibrary.rest;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import cn.leestudio.leelibrary.rest.bussness.RestApi;
import cn.leestudio.leelibrary.rest.bussness.bean.LoginReturn;
import cn.leestudio.restlib.Rest;
import cn.leestudio.restlib.RestCallback;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final RestApi api = (RestApi) new Rest().create(this, MyCall.class,RestApi.class);
//        api.test6("1", "1", "里","hanzi", new RestCallback<ResponseData<GetRecommendListReturn>>() {
//
//            @Override
//            public void onSuccess(ResponseData<GetRecommendListReturn> hashMapResponseData) {
//                Log.d("test","onSuccess -> "+hashMapResponseData.getResult().getList().get(0).getTitle());
//            }
//
//            @Override
//            public void onCache(ResponseData<GetRecommendListReturn> result) {
//                Log.d("test","onCache -> "+result.getResult().getList().get(0).getTitle());
//            }
//        });
        api.login("18684692111", "888888","User", new RestCallback<LoginReturn>() {
            @Override
            public void onError(String code, String errorMsg) {
                Log.e(this.getClass().getSimpleName(),"code -> "+code+" error -> "+errorMsg);
            }

            @Override
            public void onSuccess(LoginReturn s) {
                Log.e(this.getClass().getSimpleName(),s.getUserNick());
            }
        });
//        MyCall myCall = api.upload("4263", "test", Environment.getExternalStorageDirectory().getPath() + "/1.mp3", new RestCallback<String>() {
//            @Override
//            public void onError(String code, String errorMsg) {
//                Log.e(this.getClass().getSimpleName(),"code -> "+code+" error -> "+errorMsg);
//            }
//
//            @Override
//            public void onSuccess(String s) {
//                Log.e(this.getClass().getSimpleName(),s);
//            }
//        });
//        myCall.cancle();

    }
}
